package com.yyx.zookeeperlock.controller;

import com.yyx.zookeeperlock.service.ZookeeperLockService;
import com.yyx.zookeeperlock.utils.DistributedLock;
import com.yyx.zookeeperlock.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ZookeeperLockController {

    @Autowired
    private DistributedLock distributedLock;

    @Autowired
    private ZookeeperLockService zookeeperLockService;
    @GetMapping("/DemoBuy")
    public JSONResult DemoBuy(Integer itemId){
        boolean result = zookeeperLockService.displayBuy(itemId);
        return JSONResult.ok(result ? "订单创建成功...":"订单创建失败.....");
    }
    @GetMapping("/DemoBuy2")
    public JSONResult DemoBuy2(Integer itemId){
        boolean result = zookeeperLockService.displayBuy(itemId);
        return JSONResult.ok(result ? "订单创建成功...":"订单创建失败.....");
    }

}
